<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="keywords" content="GCMS" />
<meta name="description" content="GCMS" />
<meta name="robots" content="noindex, nofollow" />
<link rel="stylesheet" type="text/css" href="../system/application/views/style.css" media="screen" />
<link rel="stylesheet" type="text/css" href="../system/application/views/content.css" media="screen" />
<style type="text/css">
<!--
body {
	margin:0;
}
#top {
	margin-bottom:20px;
}
-->
</style>
<title>GCMS >> Installation >> Step 2</title>
</head>
<body>
	
<div id="top">
	<div style="padding-left:20px;">GCMS &gt;&gt; Installation &gt;&gt; Step 2</div>
</div>
<div style="margin:0 auto;width:700px;">
<h1>GCMS Installation &gt;&gt; Step 2</h1>
<br />
<?
$directory = "../system/application/config/";
chmod($directory, 0777);

echo 'Writing config file...<br />';
$myFile = $directory."config.php";
$fh = fopen($myFile, 'w') or die("can't open file: ".$myFile);
$data = '<?php  if (!defined(\'BASEPATH\')) exit(\'No direct script access allowed\');
$config[\'base_url\'] = "'.$_POST['url'].'";
$config[\'index_page\'] = "";
$config[\'uri_protocol\']	= "AUTO";
$config[\'url_suffix\'] = "";
$config[\'language\']	= "english";
$config[\'charset\'] = "UTF-8";
$config[\'enable_hooks\'] = FALSE;
$config[\'subclass_prefix\'] = \'MY_\';
$config[\'permitted_uri_chars\'] = \'a-z 0-9~%.:_-\';
$config[\'enable_query_strings\'] = FALSE;
$config[\'controller_trigger\'] = \'c\';
$config[\'function_trigger\'] = \'m\';
$config[\'log_threshold\'] = 0;
$config[\'log_path\'] = \'\';
$config[\'log_date_format\'] = \'Y-m-d H:i:s\';
$config[\'cache_path\'] = \'\';
$config[\'encryption_key\'] = "";
$config[\'sess_cookie_name\']		= \'ci_session\';
$config[\'sess_expiration\']		= 7200;
$config[\'sess_encrypt_cookie\']	= FALSE;
$config[\'sess_use_database\']	= FALSE;
$config[\'sess_table_name\']		= \'ci_sessions\';
$config[\'sess_match_ip\']		= FALSE;
$config[\'sess_match_useragent\']	= TRUE;
$config[\'cookie_prefix\']	= "";
$config[\'cookie_domain\']	= "";
$config[\'cookie_path\']		= "/";
$config[\'global_xss_filtering\'] = FALSE;
$config[\'compress_output\'] = FALSE;
$config[\'time_reference\'] = \'local\';
$config[\'rewrite_short_tags\'] = FALSE;
?>';
fwrite($fh, $data);
fclose($fh);

echo 'Writing database config file...<br />';
$myFile = $directory."database.php";
$fh = fopen($myFile, 'w') or die("can't open file: ".$myFile);
$data = '<?php  if (!defined(\'BASEPATH\')) exit(\'No direct script access allowed\');
$active_group = "default";
$db[\'default\'][\'hostname\'] = "'.$_POST['host'].'";
$db[\'default\'][\'username\'] = "'.$_POST['dbusername'].'";
$db[\'default\'][\'password\'] = "'.$_POST['dbpassword'].'";
$db[\'default\'][\'database\'] = "'.$_POST['dbname'].'";
$db[\'default\'][\'dbdriver\'] = "mysql";
$db[\'default\'][\'dbprefix\'] = "";
$db[\'default\'][\'active_r\'] = TRUE;
$db[\'default\'][\'pconnect\'] = TRUE;
$db[\'default\'][\'db_debug\'] = TRUE;
$db[\'default\'][\'cache_on\'] = FALSE;
$db[\'default\'][\'cachedir\'] = "";
?>';
fwrite($fh, $data);
fclose($fh);

chmod($directory, 0755);



echo 'Connecting to database...<br />';
@mysql_connect($_POST['host'], $_POST['dbusername'], $_POST['dbpassword']) or die ('Error connecting to database');
@mysql_select_db($_POST['dbname']) or die ('Error selecting database');
echo 'Populating database...<br />';

$query = "CREATE TABLE gcms_news (
  ID int(6) NOT NULL auto_increment,
  news_heading varchar(30) NOT NULL default '',
  news_content varchar(255) NOT NULL default '',
  news_date varchar(30) NOT NULL default '',
  PRIMARY KEY  (ID)
) AUTO_INCREMENT=2;";
$result = mysql_query($query);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

$query = "INSERT INTO gcms_news (ID, news_heading, news_content, news_date) VALUES 
(1, 'Test News', 'Write your news here...', '2007-09-19 16:21:09');";
$result = mysql_query($query);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

$query = "CREATE TABLE gcms_options (
  option_id bigint(20) NOT NULL auto_increment,
  option_name varchar(64) NOT NULL default '',
  option_value longtext NOT NULL,
  PRIMARY KEY  (option_id)
) AUTO_INCREMENT=3 ;";
$result = mysql_query($query);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

$query = "INSERT INTO gcms_options (option_id, option_name, option_value) VALUES
(1, 'title', 'GCMS'),
(2, 'theme', 'default');";
$result = mysql_query($query);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

$query = "CREATE TABLE gcms_posts (
  ID bigint(20) unsigned NOT NULL auto_increment,
  post_author varchar(30) NOT NULL default '',
  post_date datetime NOT NULL default '0000-00-00 00:00:00',
  post_content text NOT NULL,
  post_title varchar(50) NOT NULL default '',
  post_slug varchar(40) NOT NULL default '',
  post_order smallint(6) NOT NULL default '0',
  post_menu tinyint(2) NOT NULL default '1',
  PRIMARY KEY  (ID),
  KEY type_status_date (post_date,ID)
) AUTO_INCREMENT=2;";
$result = mysql_query($query);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

$query = "INSERT INTO gcms_posts (ID, post_author, post_date, post_content, post_title, post_slug, post_order, post_menu) VALUES
(1, 'Admin', '2007-08-09 09:23:22', '<p>Welcome to GCMS. Log in to the admin section to start using GCMS:<br /><br />Username: admin<br />Password: admin<br /><br />Note: For security reasons you must change password immediately.</p>', 'Home', 'home', 1, 1);";
$result = mysql_query($query);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

$query = "CREATE TABLE gcms_users (
  ID bigint(20) unsigned NOT NULL auto_increment,
  user_login varchar(60) NOT NULL default '',
  user_pass varchar(100) NOT NULL default '',
  user_email varchar(100) NOT NULL default '',
  user_url varchar(100) NOT NULL default '',
  display_name varchar(250) NOT NULL default '',
  PRIMARY KEY  (ID),
  KEY user_login_key (user_login)
) AUTO_INCREMENT=2 ;";
$result = mysql_query($query);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

$query = "INSERT INTO gcms_users (ID, user_login, user_pass, user_email, user_url, display_name) VALUES
(1, 'admin', '21232f297a57a5a743894a0e4a801fc3', '', '', 'admin');";
$result = mysql_query($query);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}
?>
<br />
<strong>Success</strong> GCMS successfully installed.<br />
<strong>Security Notice</strong> Please delete the "install" folder as it poses a seroius security risk.<br /><br />
<a href="../index.php">I'm finished >></a>
</div>

</body>
</html>